
import { BridgePayloads, ROUTES } from './CconfigClient';

import { JSBridgeClient } from './bridge/JSBridgeClient';
import { BaseManager, Manager } from '@shimotsuki/core';
import { JSBridgeRegister } from './bridge/JSBridgeRegister';
import { WEBVIEW_EVENTS } from './ConfigRegister';


declare module '@shimotsuki/core' {
    interface Manager {
        /**
         * 桥接 
         * @使用方法 在CconfigClient.ts和 ConfigRegister.ts 中注册桥接配置
         * 
        */
        jsBridge: JSbridge
    }
}


export class JSbridge extends BaseManager {

    /**
     *  
     * @使用示例  cat.jsBridge.client.gameEnterRoom({roomId,exp })
     */
    readonly client: JSBridgeClient<BridgePayloads>

    /**
     *@使用示例  this.addAudoListener(cat.jsBridge.register).on('event-with-parameters', (data, B) => {console.log(data)},this)
     */
    readonly register: JSBridgeRegister

    constructor(cat: Manager) {
        super(cat)
        this.client = new JSBridgeClient(ROUTES);
        this.register = new JSBridgeRegister(WEBVIEW_EVENTS)
    }
}







